package com.ciwong.epaper.modules.otherlogin;

import android.app.Activity;

import com.ciwong.epaper.modules.otherlogin.inf.OtherLoginListener;
import com.ciwong.epaper.modules.otherlogin.utils.LoginParamSharedUtil;

/**
 * 第三方登录授权控制器 Created by res-dlzhou on 2015/9/2.
 */
public class LoginController extends QQLoginAction {
    /**
     * 单例
     **/
    private static volatile LoginController instance;

    private LoginController() {

    }

    /**
     * 获取单例
     *
     * @return BookcaseSharedUtil
     */
    public static LoginController getInstance() {
        synchronized (LoginController.class) {
            if (instance == null) {
                instance = new LoginController();
            }
        }
        return instance;
    }

    /**
     * 设置登录结果回调监听
     *
     * @param listener
     */
    public void setOtherLoginListener(OtherLoginListener listener) {
        this.mListener = listener;
    }

    @Override
    public void initOtherLogin(Activity activity, AbstractLoginConfig config,
                               OtherLoginListener listener) {
        this.mActivity = activity;
        this.mLoginConfig = config;
        this.mListener = listener;
        this.mParamSharedUtil = LoginParamSharedUtil.getInstance();
    }

    /**
     * 内存回收,在onDestroy()方法中调用
     */
    public void release() {
        releaseTencent();
        releaseIWXAPI();
        instance = null;
    }

}
